import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/app_store/api_app_store_transaction_offer_type.dart';

const kRegularApiAppStoreTransactionOfferTypeValue = 'regular';
const kIntruductoryApiAppStoreTransactionOfferTypeValue = 'introductory';
const kPromotionalApiAppStoreTransactionOfferTypeValue = 'promotional';
const kSubscriptionCodeApiAppStoreTransactionOfferTypeValue = 'subscription_code';

class ApiAppStoreTransactionOfferTypeDto extends Equatable {
  const ApiAppStoreTransactionOfferTypeDto._internal({
    required this.offerTypeString,
  });

  final String offerTypeString;

  @override
  List<Object?> get props {
    return [
      offerTypeString,
    ];
  }

  factory ApiAppStoreTransactionOfferTypeDto.fromEntity(ApiAppStoreTransactionOfferType offerType) {
    late final String offerTypeString;

    if (offerType == ApiAppStoreTransactionOfferType.regular) {
      offerTypeString = kRegularApiAppStoreTransactionOfferTypeValue;
    } else if (offerType == ApiAppStoreTransactionOfferType.introductory) {
      offerTypeString = kIntruductoryApiAppStoreTransactionOfferTypeValue;
    } else if (offerType == ApiAppStoreTransactionOfferType.promotional) {
      offerTypeString = kPromotionalApiAppStoreTransactionOfferTypeValue;
    } else if (offerType == ApiAppStoreTransactionOfferType.subscriptionCode) {
      offerTypeString = kSubscriptionCodeApiAppStoreTransactionOfferTypeValue;
    }

    return ApiAppStoreTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  @override
  String toString() {
    return offerTypeString;
  }
}
